{extend name="light-year/layout/default" /}

{block name="title"}角色管理{/block}

{block name="content"}
<div class="card-toolbar clearfix">
    <div class="toolbar-btn-action">
        <a class="btn btn-primary m-r-5" href="{:url('detail') }"><i class="mdi mdi-plus"></i> 新增 </a>
        <a class="btn btn-danger" href="javascript:;" onclick="batchDelOperation('{:url(\'delete\')}');">
            <i class="mdi mdi-window-close"></i> 批量删除
        </a>
        <a class="btn btn-info m-r-5" href="javascript:;" onclick="batchExport('{:url(\'export\')}');"><i class="mdi mdi-export"></i> 导出 </a>
    </div>
    <hr>
    <form class="form-inline first_form" action="" method="get">
        <div class="form-group">
            <?php $is_check = input('is_check', -1); ?>
            <select name="is_check" class="form-control">
                <option value="-1" {if $is_check == -1}selected{/if}> 请选择状态 </option>
                <option value="1" {if $is_check == 1}selected{/if}> 正常 </option>
                <option value="0" {if $is_check == 0}selected{/if}> 禁用 </option>
            </select>
        </div>
        <div class="form-group">
            <input class="form-control" type="text" name="search" placeholder="Search ..." value="{:input('search', '')}">
        </div>
        <a class="btn btn-default" onclick="$('form').submit();"><i class="mdi mdi-magnify"></i> 搜索 </a>
        <a class="btn btn-warning" href="{:url()}"><i class="mdi mdi-block-helper"></i> 重置 </a>
    </form>
</div>
<div class="card-body">
    <div class="table-responsive">
        <table class="table table-bordered">
            <thead>
            <tr>
                <th class="text-center">
                    <label class="lyear-checkbox checkbox-primary">
                        <input type="checkbox" id="check-all"><span></span>
                    </label>
                </th>
                <th class="text-center"> Id </th>
                <th class="text-center"> 角色名称 </th>
                <th class="text-center hidden-sm hidden-xs hidden-md"> 创建时间 </th>
                <th class="text-center"> 状态 </th>
                <th class="text-center"> 操作 </th>
            </tr>
            </thead>
            <tbody>
            {if !empty($list) && $list->total()}
            {foreach $list as $key => $item}
            <tr id="id_{$item->role_id}" name="{$item->role_name}">
                <td class="text-center">
                    <label class="lyear-checkbox checkbox-primary">
                        <input type="checkbox" name="role_id[]" value="{$item->role_id}"><span></span>
                    </label>
                </td>
                <td class="text-center"> <a href="javascript:;">{$item->role_id}</a> </td>
                <td class="text-center"> {$item->role_name} </td>
                <td class="text-center hidden-sm hidden-xs hidden-md">
                    {:date('Y-m-d H:i', $item->created_time)}
                </td>
                <td class="text-center">
                    {switch $item->is_check|intval }
                    {case 1}
                    <span class="label label-success"> 正常 </span>
                    {/case}
                    {default /}
                    <span class="label label-danger"> 禁用 </span>
                    {/switch}
                </td>
                <td class="text-center">
                    <div class="hidden-sm hidden-xs action-buttons">
                        {if $item->role_id != 1}
                        {switch $item->is_check|intval }
                        {case 1}
                        <a class="btn btn-xs btn-danger" title="禁用“{$item->role_name}”角色" href="javascript:;" onclick="changeFiledStatus(this, '{:url(\'changeFiledStatus\')}', {'role_id' : '{$item->role_id}', 'change_field' : 'is_check', 'change_value':0})">
                            <i class="mdi mdi-lock-outline"></i>
                            禁用
                        </a>
                        {/case}
                        {default /}
                        <a class="btn btn-xs btn-success" title="启用“{$item->role_name}”角色" href="javascript:;" onclick="changeFiledStatus(this, '{:url(\'changeFiledStatus\')}', {'role_id' : '{$item->role_id}', 'change_field' : 'is_check', 'change_value':1})">
                            <i class="mdi mdi-lock-open-outline"></i>
                            启用
                        </a>
                        {/switch}
                        {/if}
                        <a class="btn btn-xs btn-info" title="编辑“{$item->role_name}”角色" href="{:url('detail', ['role_id' => $item->role_id])}">
                            <i class="mdi mdi-pencil"></i>
                            编辑
                        </a>
                        {if $item->role_id != 1}
                        <a class="btn btn-xs btn-danger" title="删除“{$item->role_name}”角色" onclick="delOperation({$item->role_id}, '{:url(\'delete\')}')">
                            <i class="mdi mdi-window-close"></i>
                            删除
                        </a>
                        {/if}
                    </div>
                    <div class="hidden-md hidden-lg">
                        <div class="inline position-relative">
                            <button class="btn btn-minier btn-primary dropdown-toggle" data-toggle="dropdown" data-position="auto">
                                <i class="mdi mdi-settings small"></i>
                            </button>
                            <ul class="dropdown-menu dropdown-only-icon dropdown-yellow dropdown-menu-right dropdown-caret dropdown-close">
                                {if $item->role_id != 1}
                                {switch $item->is_check|intval }
                                {case 1}
                                <li>
                                    <a class="btn btn-xs btn-danger" title="禁用“{$item->role_name}”角色" href="javascript:;" onclick="changeFiledStatus(this, '{:url(\'changeFiledStatus\')}', {'role_id' : '{$item->role_id}', 'change_field' : 'is_check', 'change_value':0})">
                                        <i class="mdi mdi-lock-outline"></i>
                                        禁用
                                    </a>
                                    <hr>
                                </li>
                                {/case}
                                {default /}
                                <li>
                                    <a class="btn btn-xs btn-success" title="启用“{$item->role_name}”角色" href="javascript:;" onclick="changeFiledStatus(this, '{:url(\'changeFiledStatus\')}', {'role_id' : '{$item->role_id}', 'change_field' : 'is_check', 'change_value':1})">
                                        <i class="mdi mdi-lock-open-outline"></i>
                                        启用
                                    </a>
                                    <hr>
                                </li>
                                {/switch}
                                {/if}
                                <li>
                                    <a class="btn btn-xs btn-info" title="编辑“{$item->role_name}”角色" href="{:url('detail', ['role_id' => $item->role_id])}">
                                        <i class="mdi mdi-pencil"></i>
                                        编辑
                                    </a>
                                </li>
                                {if $item->role_id != 1}
                                <li>
                                    <hr>
                                    <a class="btn btn-xs btn-danger" title="删除“{$item->role_name}”角色" onclick="delOperation({$item->role_id}, '{:url(\'delete\')}')">
                                        <i class="mdi mdi-window-close"></i>
                                        删除
                                    </a>
                                </li>
                                {/if}
                            </ul>
                        </div>
                    </div>
                </td>
            </tr>
            {/foreach}
            {else/}
            <tr class="text-center">
                <td colspan="100"> 暂无数据！ </td>
            </tr>
            {/if}
            </tbody>
        </table>
    </div>
    {if !empty($list) && $list->total()}
        <hr>
        <div id="pageList" class="float-right">
            {$list|raw}
        </div>
        <div class="clearfix"></div>
    {/if}
</div>
{/block}

{block name="script-src"}
{/block}

{block name="script"}
<script type="text/javascript">

</script>
{/block}